﻿using Engine;
using Engine.Graphics;

namespace Game
{
    public abstract class FCSixFaceBlock : Block
    {
        public Texture2D m_texture;

        public string m_texturename;

        public Color m_color;

        public FCSixFaceBlock(string texturename, Color color)
        {
            m_texturename = texturename;
            m_color = color;
        }

        public override void Initialize()
        {
            m_texture = ContentManager.Get<Texture2D>(m_texturename);
        }

        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
            generator.GenerateCubeVertices(this, value, x, y, z, m_color, geometry.GetGeometry(m_texture).OpaqueSubsetsByFace);
        }

        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {
            BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size), ref matrix, m_color, m_color, environmentData, m_texture);
        }

        public override int GetTextureSlotCount(int value)
        {
            return 3;
        }

        public override int GetFaceTextureSlot(int face, int value)
        {
            switch (face)
            {
                case 0:
                    return 0;
                case 1:
                    return 1;
                case 2:
                    return 2;
                case 3:
                    return 3;
                case 4:
                    return 4;
                case 5:
                    return 5;
                default:
                    return 0;
            }
        

    }
}
}